package arcane.network;

import ggn.client.DefaultClient;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Vector;

import arcane.constant.Constants;

public class ArcaneClient extends DefaultClient {
	/**
	 * When in lounge, holds details about all available rooms.
	 */
	protected Vector<RoomDetail> roomNames;

	/**
	 * Holds the names of clients within the same room as this client.
	 */
	protected Vector<String> partyNames;

	public ArcaneClient(String serverName, int port) throws IOException {
		super(serverName, port);
		roomNames = new Vector<RoomDetail>();
		partyNames = new Vector<String>();

		// server sends commands that reference these objects
		putObject(roomNames, Constants.ROOM_REF);
		putObject(partyNames, Constants.PARTY_REF);

	}

	public Vector<RoomDetail> getRoomNames() {
		return roomNames;
	}
	
	public Vector<String> getPartyNames(){
		return partyNames;
	}

	/**
	 * Writes data about this client back to server immediately after connection
	 * is established.
	 */
	public void initializeClient(ObjectInputStream ois, ObjectOutputStream oos) {
	}

	public void readFromServer(Object obj) {
		System.out.println("Read " + obj + " from server");
		if (obj instanceof String) {
			String s = obj.toString();
			this.executeCommand(s);
		}
	}
}
